package com.mallcloud.mall.admin.controller;

import com.mallcloud.mall.admin.api.dto.UserDTO;
import com.mallcloud.mall.admin.service.SysUserService;
import com.mallcloud.mall.common.core.util.R;
import com.mallcloud.mall.common.log.annotation.SysLog;
import com.mallcloud.mall.common.security.annotation.Inner;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "客户端注册功能")
@ConditionalOnProperty(name = "register.user", matchIfMissing = true)
@RestController
@RequiredArgsConstructor
@RequestMapping("/register")
public class RegisterController {
	private final SysUserService userService;

	@ApiOperation("注册用户")
	@Inner(value = false)
	@SysLog("注册用户")
	@PostMapping("/user")
	public R<Boolean> registerUser(@RequestBody UserDTO userDto) {
		return userService.registerUser(userDto);
	}

	@ApiOperation("注册微信小程序用户")
	@Inner(value = false)
	@SysLog("注册微信小程序用户")
	@PostMapping("/user/mini")
	public R<Boolean> registerMallUser(@Validated @RequestBody String openId) {
		return userService.registerMallUser(openId);
	}

}
